#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
namespace bit {
	class string {
	public:
		string(const char* str = "");
		string(const string& str);
		~string();
		const char* c_str();
		const char* c_str()const;
		size_t size()const;
		size_t capacity();
		char& operator[](size_t pos);
		const char& operator[](size_t pos)const;
		typedef char* iterator;
		typedef const char* const_iterator;
		const_iterator begin()const;
		const_iterator end()const;
		iterator begin();
		iterator end();
		void reserve(size_t n);
		void push_back(char ch);
		void append(const char* str);
		string& operator+=(char ch);
		string& operator+=(const char* str);
		string& operator=(string str);
		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* str);
		void erase(size_t pos, size_t len = npos);
		void swap(string& str);
		size_t find(const char* str, size_t pos = npos);
		size_t find(char ch, size_t pos = 0);
		string substr(size_t pos = 0, size_t len = npos);
		void clear();
		//friend ostream& operator<<(ostream& out, const string& str);
		friend istream& operator>>(istream& in, string& str);
	private:
		char* _str;
		size_t _size;
		size_t _capacity;
		const static size_t npos = -1;
	};
	ostream& operator<<(ostream& out, const string& str);
	istream& operator>>(istream& in, string& str);
	void print_str(const string& str);
}